<template>
    <div id="app">
        <Navs v-if="titles" v-bind:titles="titles" :title_url="title_url"/>
        <Detail v-bind:book_info="book_info"/>
        <Loading v-show="isLoading"/>
        <Welfare />
        <Author v-bind:author_book = "author_book"/>
        <ChapterList v-bind:chapter_list = "chapter_list" :new_chapter_list="new_chapter_list"/>
    </div>
</template>

<style>
</style>

<script>
    // import Home from './views/Home';
    import Loading from '../components/loadding';
    import Navs from '../components/navs';
    import Welfare from '../components/info/welfare';
    import Detail from '../components/info/detail';
    import Author from '../components/info/author';
    import ChapterList from '../components/chapter/list';
    import {getBookInfo,getAuthorBook,getChapterList,getNewChapterList} from "../service/getData";
    export default {
        components:{
            // Home,
            Navs,
            Detail,
            Welfare,
            Author,
            ChapterList,
            Loading
        },
        data(){
          return {
              book_info:null,
              isLoading:true,
              author_book:null,
              chapter_list:null,
              new_chapter_list:null,
              titles:"书籍详情",
              title_url:"Home"
          }
        },
        async created() {
            this.isLoading = true;
            let book_info_response = await getBookInfo(this.$route.params.book_id);
            // console.log(this.book_info);
            // console.log(book_info_response.data);
            this.book_info = book_info_response.data;
            let author_book_response = await getAuthorBook(this.$route.params.book_id);
            this.author_book = author_book_response.data;
            let get_chapter_list_response = await getChapterList(this.$route.params.book_id);
            this.chapter_list = get_chapter_list_response.data;
            // console.log(this.chapter_list);
            let get_new_chapter_list = await getNewChapterList(this.$route.params.book_id);
            this.new_chapter_list = get_new_chapter_list.data;
            // console.log(this.new_chapter_list);
            this.isLoading = false;
        }
    }
</script>
